In response to https://github.com/MatthewDaws/TileMapBase/issues/1
Unlike basemap, TileMapBase doesn't provide it's own plotting interface, but just draws tiles into a normal matplotlib axes. So anything you can do in matplotlib you can continue to do, while remembering:
In [4]:
%matplotlib inline
import matplotlib.pyplot as plt
import tilemapbase
tilemapbase.init(create=True)
In [32]:
# Define the `extent`
my_office = (-1.554934, 53.804198)
degree_range = 0.003
extent = tilemapbase.Extent.from_lonlat(my_office[0] - degree_range, my_office[0] + degree_range,
my_office[1] - degree_range, my_office[1] + degree_range)
extent = extent.to_aspect(1.0)
extent
Out[32]:
In [33]:
# The path to plot
longs = [-1.554934, -1.555, -1.5552, -1.554]
lats = [53.804198, 53.80416, 53.8041, 53.8042]
# Convert to web mercator
path = [tilemapbase.project(x,y) for x,y in zip(longs, lats)]
x, y = zip(*path)
In [34]:
fig, ax = plt.subplots(figsize=(10,10))
plotter = tilemapbase.Plotter(extent, tilemapbase.tiles.build_OSM(), width=600)
plotter.plot(ax)
ax.plot(x, y, "ro-")
Out[34]:
In [35]:
# Or using the plt interface
plotter.plot(plt.axes())
plt.plot(x,y, "ro-")
Out[35]:
In [ ]: